import {Component, OnInit} from '@angular/core';
import {Router} from "@angular/router";

@Component({
    selector: 'app-menu',
    templateUrl: './menu.component.html',
    styleUrls: ['./menu.component.css']
})
export class MenuComponent implements OnInit {

    menus: Array<Menu>;

    currentMenuId: number;

    constructor(public router: Router) {
    }

    ngOnInit() {
        this.menus = [
            new Menu(1, '首页', 'dashboard'),
            new Menu(2, '股票管理', 'stock'),
            new Menu(3, '新闻管理', 'news'),
            new Menu(4, '广告管理', 'advert'),
            new Menu(5, '留言管理', 'message')
        ];

    }

    nav(menu) {
        this.router.navigateByUrl(menu.link);

        this.currentMenuId = menu.id;
    }

}

export class Menu {
    constructor(public id: number,
                public name: string,
                public link: string) {

    }
}
